function [ Y ] = gsclassify( X, HP, LISTS )
N = size(X,1);
Y = zeros(N,1);

C = 48;
Table = zeros(C*C, 62);
Index = zeros(C*C, 1);
k = 0;
for a = (1:C)
    for b = (1:C)
        k = k+1;
        Index(a,b) = k;
        Table(k,:) = squeeze(HP(a,b,:));
    end
end

[N M] = size(LISTS);

a = ones(N,1);
b = ones(N,1)*M;
for i = (2:M)
    v = [X ones(N,1)] .* Table( Index( sub2ind(size(Index),LISTS( sub2ind(size(LISTS),(1:N)',a) ),LISTS( sub2ind(size(LISTS),(1:N)',b) )) ), : ) * ones(62,1);
    a( v < 0 ) = a( v < 0 ) + 1;
    b( v >= 0 ) = b( v >= 0 ) - 1;
end
Y = LISTS(sub2ind(size(LISTS),(1:N)',a));

end